<template>
  <MyDialog @cancel="isOpen = false" @confirm="handleConfirm" v-model="isOpen" :title="title">
    <ListForm ref="listFormRef" v-bind="$attrs" @done="isOpen = false" />
  </MyDialog>
</template>

<script setup lang="ts">
import { ref } from "vue";
import ListForm from "./ListForm.vue";
import MyDialog from "@/components/MyDialog/index.vue";

const isOpen = ref(false);
const title = ref("新增");

function init() {
  isOpen.value = true;
}

const listFormRef = ref<InstanceType<typeof ListForm>>();

function handleConfirm() {
  listFormRef.value?.submit();
}

defineExpose({ init });
</script>
